#ifdef MT4DLL_EXPORTS
#define MT4DLL_API __declspec(dllexport)
#else
#define MT4DLL_API __declspec(dllimport)
#endif

#ifndef BOOL
typedef int BOOL;
#endif

struct MqlStr
{
	int               len;
	char             *string;
};

//-----------------------------------------------------------------
//Server initialization
//Return:   0 if OK
//			-1 if has been initialized
//			-2 if Could not open file mapping object
//			-3 if Could not map view of file
//			-4 if queuelen is not appropriate
//-----------------------------------------------------------------
MT4DLL_API int __stdcall ServerInit(unsigned queuelen, BOOL logging);

//-----------------------------------------------------------------
//Server uninitialization
//-----------------------------------------------------------------
MT4DLL_API void __stdcall ServerUnInit(void);

//-----------------------------------------------------------------
//Send msgs to client
//First accept for new clients, then send msg to all clients
//Return:	0 if OK
//			-1 if not initialized
//			-2 if message is too large
//-----------------------------------------------------------------
MT4DLL_API int __stdcall Send(MqlStr * msg, int len);

//-----------------------------------------------------------------
//Client initialization
//Return:	0 if OK
//			-1 if has been initialized
//			-2 if Could not open file mapping object
//			-3 if Could not map view of file--phase 1
//			-4 if Version or queue length mismatch
//			-5 if Could not find start position
//			-6 if Could not map view of file--phase 2
//-----------------------------------------------------------------
MT4DLL_API int __stdcall ClientInit(BOOL logging);

//-----------------------------------------------------------------
//Client uninitialization
//-----------------------------------------------------------------
MT4DLL_API void __stdcall ClientUnInit(void);

//-----------------------------------------------------------------
//Receive a msg from server
//Return:	0 if no data
//			>0 if succeed, 
//					return value is the number of record received
//			-1 if not initialized
//			-2 if mqlstr.string is NULL
//			-3 if mqlstr has not enough buf
//-----------------------------------------------------------------
MT4DLL_API int __stdcall Receive(MqlStr * buf, int arraylen);
